package com.chengcang.api.modules.sys.controller;

import com.chengcang.api.common.annotation.Login;
import com.chengcang.api.modules.login.utils.UserHolder;
import com.chengcang.api.modules.sys.dto.SysUserDTO;
import com.chengcang.common.utils.ConvertUtils;
import com.chengcang.common.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author fankunfeng
 * @date 2023-02-10 13:46:08
 **/
@RestController
@Api(tags = "用户管理")
@RequestMapping("user")
public class SysUserController {

    @GetMapping("info")
    @ApiOperation("登录用户信息")
    @Login
    public Result<SysUserDTO> info(){
        SysUserDTO data = ConvertUtils.sourceToTarget(UserHolder.getUser(), SysUserDTO.class);
        return new Result<SysUserDTO>().ok(data);
    }

}
